class Solution(object):
    def tictactoe(self, moves):
        """
        :type moves: List[List[int]]
        :rtype: str
        """
        h_count = [0] * 3
        v_count = [0] * 3
        c_count = [0] * 2
        n = len(moves)
        if n % 2 == 1:
            for i in range(0, n, 2):
                h_count[moves[i][0]] += 1
                if h_count[moves[i][0]] == 3:
                    return 'A'
                v_count[moves[i][1]] += 1
                if v_count[moves[i][1]] == 3:
                    return 'A'
                if moves[i][0] == moves[i][1]:
                    c_count[0] += 1
                    if c_count[0] == 3:
                        return 'A'
                if moves[i][0] + moves[i][1] == 2:
                    c_count[1] += 1
                    if c_count[1] == 3:
                        return 'A'
            if n < 9:
                return 'Pending'
            else:
                return 'Draw'
        else:
            for i in range(1, n, 2):
                h_count[moves[i][0]] += 1
                if h_count[moves[i][0]] == 3:
                    return 'B'
                v_count[moves[i][1]] += 1
                if v_count[moves[i][1]] == 3:
                    return 'B'
                if moves[i][0] == moves[i][1]:
                    c_count[0] += 1
                    if c_count[0] == 3:
                        return 'B'
                if moves[i][0] + moves[i][1] == 2:
                    c_count[1] += 1
                    if c_count[1] == 3:
                        return 'B'
            return 'Pending'


data = Solution()
moves = [[2, 0], [1, 1], [0, 2], [2, 1], [1, 2], [1, 0], [0, 0], [0, 1]]
print(data.tictactoe(moves))
